#include <bits/stdc++.h>
// 2025/01/18
// tag: simulation
// Author: Zhang Muen
using namespace std;

inline int HASH(int a, int b, int c, int d, int e, int f){
    return a + b * 10 + c * 100 + d * 1000 + e * 10000 + f * 100000;
}

char m[12][12];
bool vis[2000001];
int cowx, cowy, farmerx, farmery, cowdir, farmerdir;
int dy[4] = {0, 1, 0, -1}, dx[4] = {-1, 0, 1, 0};

inline void move(){
    if (m[cowx + dx[cowdir]][cowy + dy[cowdir]] != '.')
        cowdir = (cowdir + 1) % 4;
    else 
        cowx += dx[cowdir], cowy += dy[cowdir];
    if (m[farmerx + dx[farmerdir]][farmery + dy[farmerdir]]!= '.')
        farmerdir = (farmerdir + 1) % 4;
    else
        farmerx += dx[farmerdir], farmery += dy[farmerdir];
}

signed main()
{
    for (int i = 1; i <= 10; i++)
        cin >> m[i] + 1;
    for (int i = 1; i <= 10; i++) // find the cow and farmer
        for (int j = 1; j <= 10; j++)
            if (m[i][j] == 'C')
                cowx = i, cowy = j, m[i][j] = '.';
            else if (m[i][j] == 'F')
                farmerx = i, farmery = j, m[i][j] = '.';

    int ans = 0;
    while (true){ // simulation
        ans++;
        move();
        if (cowx == farmerx && cowy == farmery)
            break;
        if (vis[HASH(cowx, cowy, cowdir, farmerx, farmery, farmerdir)]){
            cout << 0;
            return 0;
        }
        vis[HASH(cowx, cowy, cowdir, farmerx, farmery, farmerdir)] = true;
    }
    cout << ans;
    return 0;
}